﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace WoWTCG
{
    public class CardLibrary
    {
        private List<Card> cards;
        private Dictionary<string, Deck> decks;

        public CardLibrary()
        {
            cards = new List<Card>();
            decks = new Dictionary<string, Deck>();
            LoadCards();
        }

        private List<string> _setList;
        public string[] SetList
        {
            get
            {
                if (_setList == null)
                {
                    _setList = new List<string>();
                    foreach (Card c in cards)
                    {
                        if (!_setList.Contains(c.Set.ToString()))
                            _setList.Add(c.Set.ToString());
                    }
                }
                return _setList.ToArray();
            }
        }

        public List<Card> Cards
        {
            get
            { return this.cards; }
        }

        private void LoadCards()
        {
            // load heroes of azeroth set
            StreamReader reader = new StreamReader("Cards/hoa-data.txt");
            string line = "";
            // throw out first line (headings)
            reader.ReadLine();
            while ((line = reader.ReadLine()) != null)
            {
                string[] parts = line.Split('\t');
                cards.Add(new Card(parts, "HeroesOfAzeroth"));
            }
        }
    }
}
